/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.EmployeeDAOInterface;
import org.cuatrovientos.erp.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author pablo_guerrero
 * This class implements EmployeeBOInterface
 */
public class EmployeeBO implements EmployeeBOInterface{
	// Get log4j logger
		private static final Logger logger = Logger.getLogger(EmployeeBO.class);
		
		@Autowired
	    private EmployeeDAOInterface employeeDAO;
		
	/**
	 * @param int id
	 * @return Employee employee
	 * This method returns a employee selected by it's id
	 */
	@Override
	public Employee selectById(int id) {
		logger.info("selectById: " + id);
		return employeeDAO.selectById(id);
	}
	
	/**
	 * @return All the employees we have in the database
	 */
	@Override
	public List<Employee> selectAll() {
		logger.info("selectAll: ");
		return employeeDAO.selectAll();
	}
	
	/**
	 * @return The number of employees we have in the database
	 */
	@Override
	public List<Employee> search(String name) {
		logger.info("search : " + name);
		return employeeDAO.search(name);
	}
	
	/**
	 * @param int id
	 * This method deletes the employee selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		employeeDAO.deleteById(id);
	}
	
	/**
	 * @param Employee employee
	 * This method insert a employee in the database passed by parameter
	 */
	@Override
	public void insert(Employee employee) {
		logger.info("insert: " + employee);
		employeeDAO.insert(employee);
	}
	
	/**
	 * @param Employee employee
	 * This method updates a employee passed by parameter
	 */
	@Override
	public void update(Employee employee) {
		logger.info("update: " + employee);
		employeeDAO.update(employee);
	}
	
	/**
	 * @param Employee employee
	 * This method deletes a employee passed by parameter
	 */
	@Override
	public void delete(Employee employee) {
		logger.info("delete: " + employee);
		employeeDAO.delete(employee);
	}

}
